using Dapr.Client;
using Dapr.Extensions.Configuration;
using Dcy.Dapr.Client.GrpcServices;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddGrpc();
builder.Services.AddControllers().AddDapr();
// Create Dapr Client 为了使用Configuration[xx] 直接取值
var daprClient = new DaprClientBuilder().Build();
builder.Configuration.AddDaprSecretStore("localSecretStore", daprClient,TimeSpan.FromSeconds(10));
builder.Configuration.AddDaprConfigurationStore("configStore", [],daprClient,TimeSpan.FromSeconds(10));
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();
app.UseCloudEvents();
app.MapSubscribeHandler();
app.MapControllers();
app.MapGrpcService<ClientRemoteService>();
app.Run();